#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=6405,mod=1e9+7;
int n,a[Maxn],fac[Maxn];
inline int ksm(int a,int k){
	int res=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1)res=res*a%mod;
	return res;
}
int ans1,ans;
int g[Maxn],b[Maxn],c[Maxn<<1],vis[Maxn];
void dfs(int x){
	if(x==n+1){
		for(int i=1;i<=n;i++)
			b[i]=a[g[i]];
		int len=0;
		c[++len]=114514;
		for(int i=1;i<=n;i++)c[++len]=b[i],c[++len]=114514;
		int res=0;
		for(int i=1;i<=len;i++){
			int tmp=1;
			while(i-tmp>0&&i+tmp<=len&&c[i-tmp]==c[i+tmp])tmp++;
			res+=(tmp)/2;
		}
//		if(res!=7){
//			printf("fwef %d\n",res);
//			for(int i=1;i<=n;i++)printf("%d ",b[i]);
//			puts("");
//		}
		if(ans1<res)ans1=res,ans=1;
		else if(ans1==res)ans++;
		return;
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])g[x]=i,vis[i]=1,dfs(x+1),vis[i]=0;
}
signed main(){
	freopen("palindrome.in","r",stdin);
	freopen("palindrome.out","w",stdout);
	n=read();fac[0]=1;
	for(int i=1;i<=n;i++)a[i]=read(),fac[i]=fac[i-1]*i%mod;
	dfs(1);
	for(int i=1;i<=n;i++)vis[a[i]]++;
	for(int i=1;i<=80;i++)ans=ans*ksm(fac[vis[i]],mod-2)%mod;
	printf("%lld %lld\n",ans1,ans);
	return 0;
}
/*
3 2 1 1 2
*/
